package com.gxa.service.investment.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.investmentDto.IntentionRegisterQuitDto;
import com.gxa.entity.investment.OccupancyRegister;
import com.gxa.entity.investment.ProjectClose;
import com.gxa.mapper.investment.ProjectCloseMapper;
import com.gxa.service.investment.ProjectCloseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.vo.investmentVo.ProjectCloseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 项目关闭表 服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-17 03:04:36
 */
@Service
public class ProjectCloseServiceImpl extends ServiceImpl<ProjectCloseMapper, ProjectClose> implements ProjectCloseService {

    @Autowired
    private ProjectCloseMapper projectCloseMapper;

    //查询所有
    @Override
    public List<ProjectCloseVo> seletAll() {
        return projectCloseMapper.listAll();
    }

    @Override
    public ProjectCloseVo quitById(Integer id) {
        return projectCloseMapper.queryById(id);
    }

    @Override
    public PageInfo<ProjectCloseVo> queryByProjectClose(IntentionRegisterQuitDto intentionRegisterQuitDto, Integer pageNum, Integer pageSize) {
        Page<ProjectCloseVo> page = PageHelper.startPage(pageNum,pageSize);
        List<ProjectCloseVo> projectCloseVoList = this.projectCloseMapper.queryByProjectClose(intentionRegisterQuitDto);
        PageInfo<ProjectCloseVo> pageInfo = new PageInfo<>(projectCloseVoList);

        return pageInfo;
    }

    //修改状态
    @Override
    public void updateToState(Integer id, Integer state) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("id",id);
        updateWrapper.set("state", state);
        projectCloseMapper.update(null, updateWrapper);
    }

    @Override
    public void add(ProjectClose projectClose) {
        projectCloseMapper.insert(projectClose);
    }
}
